#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+1;
int a[N],b[N],c[N],d[N],n,m,l,v,cnt,ans;bool vis[N];
inline bool check()
{
	int sum=0;
	for(int i=1;i<=n;++i)
	{
		int o=0;
		for(int j=1;j<=m;++j)
		{
			//cout<<i<<' '<<j<<' '<<a[i]<<' '<<d[j]<<endl;
			int s=d[j]-a[i];
			if(s<0||vis[j]==0)continue;
			long double vv=b[i]*b[i]+2*c[i]*s;
			if(vv<=0)vv=0;else vv=sqrt(vv);
			//cout<<vv<<' '<<v<<endl;
			if(vv>v)o=1;
			//break;
		}
		sum+=o;//break;
	}
	return sum==cnt;
}
inline int calc()
{
	int res=0;
	for(int i=1;i<=m;++i)
		if(vis[i]==0)res++;
	return res;
}
inline void dfs(int d)
{
  //  puts("SAFE");
	if(d>m)
	{
	    //if(calc()==1&&check()==1){for(int i=1;i<=n;++i)cout<<vis[i]<<' ';cout<<endl;}
        if(check())ans=max(ans,calc());
        return;
    }
    else
    {
        vis[d]=1;dfs(d+1);
        vis[d]=0;dfs(d+1);
	}
}
inline void solve()
{
    //A qidian B chusudu(v0) C jiasudu(a)
	int flagA=1,flagB=1;
	cin>>n>>m>>l>>v;ans=n;cnt=0;
	for(int i=1;i<=n;++i)cin>>a[i]>>b[i]>>c[i];//,cout<<a[i]<<' '<<b[i]<<' '<<c[i]<<endl;
	for(int i=1;i<=m;++i)cin>>d[i],vis[i]=0;//cout<<d[i]<<' ';
	sort(d+1,d+m+1);
	for(int i=1;i<=n;++i)
    {
		if(c[i]!=0)flagA=0;
		if(c[i]<=0)flagB=0;
    }
    if(n<=20)flagA=flagB=0;
	if(flagA==1)
	{
		int flg=0;cnt=0;
		for(int i=1;i<=n;++i)
		{
			if(a[i]>d[m])continue;
			if(b[i]>v)
			{
				cnt++;flg=1;
			}
		}
		printf("%lld %lld\n",cnt,n-flg);
		return;
	}
    if(flagB==1)
    {
        int flg=0;cnt=0;
        for(int i=1;i<=n;++i)
        {
            if(a[i]>d[m])continue;int s=d[m]-a[i];
            long double vv=b[i]*b[i]+2*c[i]*s;
			if(vv<=0)vv=0;else vv=sqrt(vv);
			if(vv>v)cnt++,flg=1;
        }
        printf("%lld %lld\n",cnt,n-flg);
		return;
    }
    ans=0;
	for(int i=1;i<=n;++i)
	{
		int o=0;
		for(int j=1;j<=m;++j)
		{
			//cout<<i<<' '<<j<<' '<<a[i]<<' '<<d[j]<<endl;
			int s=d[j]-a[i];
			if(s<0)continue;
			long double vv=b[i]*b[i]+2*c[i]*s;
			if(vv<=0)vv=0;else vv=sqrt(vv);
			//cout<<vv<<' '<<v<<endl;
			if(vv>v)o=1;
			//break;
		}
		cnt+=o;//break;
	}
	dfs(1);
	printf("%lld %lld\n",cnt,ans);
}
signed main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int _;cin>>_;
	while(_--)solve();
	fclose(stdin);
	fclose(stdout);
	return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 ‐2
6 4 ‐4
2 5 8 9 15*/
